-
Simplicity
-
Model binding simplifies the code by automatically mapping data from HTTP requests to action method parameters. You don’t need to write any
code to manually extract values from the request.
-
Type Safety
-
Model binding provides type safety by automatically converting the incoming data into the appropriate .NET types. If the conversion fails, the
model state becomes invalid, which you can easily check using ModelState.IsValid
.
-
Validation
-
With model binding, you can easily apply validation rules to your models using data annotations. If the incoming data doesn’t comply with these
rules, the model state becomes invalid.
-
Security
-
Model binding helps protect against over-posting attacks by only including properties in the model that you explicitly bind using the
[Bind]
attribute or by using view models that only contain the properties you want to update.
-
Maintainability
-
By using model binding, your code becomes cleaner, easier to read, and maintain. It promotes the use of strongly typed views, which can provide
compile-time checking of your views.